package com.zzhua.cglib;

import com.zzhua.cglib.callback.Callback_0;
import com.zzhua.cglib.service.UserServiceImpl;
import net.sf.cglib.core.DebuggingClassWriter;
import net.sf.cglib.proxy.Enhancer;
import sun.misc.ProxyGenerator;

/**
 * @description
 * @Author: zzhua
 * @Date 2022/1/7
 */
public class Test02 {
    public static void main(String[] args) {

        // System.setProperty("sun.misc.ProxyGenerator.saveGeneratedFiles", "D:\\Projects\\learning\\proxy-dynamic-demo\\target\\classes");
        System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, "D:\\Projects\\learning\\proxy-dynamic-demo\\target\\classes");

        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(UserServiceImpl.class);
        Callback_0 callback_0 = new Callback_0();
        enhancer.setCallback(callback_0);

        UserServiceImpl userService = (UserServiceImpl) enhancer.create();
        userService.say();

    }
}
